import React, { Component } from 'react'
import {OriginArea} from './tool'

export default class FlowerList extends Component {
    render() {
        const {list, collection, addItem} = this.props;
        return (
            <div>
                <h2>鲜花列表</h2>
                {
                    list.map( item=>{
                        return <div className='list' key={item.plantID}>
                            <img src={item.coverURL}/>
                            <p>{item.name}</p>
                            <p>{item.engName}</p>
                            <p>产地：{OriginArea(item.area)}</p>
                            <button onClick={()=>addItem(item)}>{collection.indexOf(item) === -1 ? '收藏' : '已收藏'}</button>
                            </div>   
                    })
                }
            </div>
        )
    }
}
